import { ConsultType } from '@/enums'
import type { ConsultIllness, PartialConsult } from '@/types/consult'
import { defineStore } from 'pinia'
import { ref } from 'vue'
export const useConsultStore = defineStore(
  'cp-consult',
  () => {
    //定义存储变量 state
    const consult = ref<PartialConsult>({})
    // 定义存储问诊类型的函数
    const setType = (type: ConsultType) => {
      consult.value.type = type
    }
    // 存储极速问诊的类型
    const setIllnesType = (type: 0 | 1) => {
      consult.value.illnessType = type
    }

    // 存储科室的id
    const setDep = (id: string) => {
      consult.value.depId = id
    }
    // 设置存储患者的基本信息
    const setIllness = (Illness: ConsultIllness) => {
      consult.value.illnessDesc = Illness.illnessDesc
      consult.value.illnessTime = Illness.illnessTime
      consult.value.consultFlag = Illness.consultFlag
      consult.value.pictures = Illness.pictures
    }
    // 设置 存储患者的id
    const setPatient = (id: string) => (consult.value.patientId = id)
    return { setType, consult, setIllnesType, setDep, setIllness, setPatient }
  },
  {
    // 是否开启永久存储
    persist: true
  }
)
